package cn.yyvtc.workorderms.project.controller;

import cn.yyvtc.base.ResData;
import cn.yyvtc.workorderms.project.entity.ProjectEntity;
import cn.yyvtc.workorderms.project.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 黄后林
 * @date 2022-11-01 11:14:39
 * @note 程序员是用代码喂出来的
 */

@RestController
@RequestMapping("project")
public class ProjectController {

    @Autowired
    private ProjectService service;

    //http://localhost:8081/project/all
    @GetMapping("all")
    public ResData findById(){
        List<ProjectEntity> list = service.findAll();
        return ResData.getSuccessResData(list);

    }

    //http://localhost:8081/project/find?id=1
    @GetMapping("find")
    public ResData findById(Long id){
        return ResData.getSuccessResData(service.findById(id));
    }
}
